package com.ll.menu.user.menu;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.droid.library.app.App;
import com.droid.library.app.adapter.BaseAbstractAdapter;
import com.ll.menu.user.R;
import com.ll.menu.user.app.entity.MenuItem;

/**
 * MenuItem菜单列表
 *
 * @author wangheng
 */
public class MenuListAdapter extends BaseAbstractAdapter<MenuItem> {

    private int colorTextBgSelect = App.getInstance().getResources().getColor(R.color.color_orange_20);
    private int colorDividerBgSelect = App.getInstance().getResources().getColor(R.color.color_orange);

    @Override
    protected int getLayoutId() {
        return R.layout.item_menu_item;
    }

    @Override
    protected void inflate(View convertView, MenuItem menuItem, int position) {
        TextView title = (TextView) findViewById(R.id.tvMenuItemTitle);
        View divider = findViewById(R.id.viewMenuItemDivider);

        title.setText(menuItem.getTitle());

        if(menuItem.isSelect()){
            title.setBackgroundColor(colorTextBgSelect);
            divider.setBackgroundColor(colorDividerBgSelect);
        }else{
            title.setBackgroundColor(Color.TRANSPARENT);
            divider.setBackgroundColor(Color.TRANSPARENT);
        }
    }
}
